'use strict';

angular.module('myApp.competition_detail', [])

.controller('competition_detailCtrl', ['$scope','$routeParams','$http',
    function($scope,$routeParams,$http,$location) {
    	$scope.comd =  $routeParams.id;

    $http.get('v1/competition/'+ $routeParams.id + '/detail').success(function(data){
        $scope.model = data.result;
    });

    $scope.del = function(m){
    	
	    $http.delete('v1/competition/'+m.cp_id+'/detail/'+m.id).success(function(data){
			if( !data.error ){
				alert("删除成功","success");
				$http.get('v1/competition/'+ $routeParams.id + '/detail').success(function(data){
			        $scope.model = data.result;
			    });
			}else{
				alert(data.message);
			}
	    });
    };
    $scope.search = function(m){
	    $http.get('v1/competition/'+ m.cp_id+ '/detail/'+m.id).success(function(data){
	        $scope.result = data.result['0'];
	        $("iframe").contents().find("body").append(data);
	        console.log(data);
	    });
    };
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="content"]', {
			resizeType : 1,
			allowPreviewEmoticons : false,
			allowImageUpload : false,
			items : [
				'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons', 'image', 'link']
		});
	});	

}]);